import 'package:school_safe_teacher/Home/entity/homeClassEntity.dart';
import 'package:school_safe_teacher/Home/entity/news_entity.dart';
import 'package:school_safe_teacher/homeWorkList/entity/homeWorkListEntity.dart';
import 'package:school_safe_teacher/me/entity/userEntity.dart';
import 'package:school_safe_teacher/login/entity/login_entity.dart';
import 'package:school_safe_teacher/login/entity/login_entity.dart';
import 'package:school_safe_teacher/message/entity/message_entity.dart';
import 'package:school_safe_teacher/studentsReview/entity/studentReviewEntity.dart';
import 'package:school_safe_teacher/attendanceRecord/entity/attendanceRecordEntity.dart';
import 'package:school_safe_teacher/user_info/upload_entity.dart';
class EntityFactory {
  static S generateOBJ<S, T>(json) {
    if (S.toString() == "String") {
      return json.toString() as S;
    } else if (T.toString() == "Map<dynamic, dynamic>") {
      return json as S;
    } else {
      return _generateOBJ(json);
    }
  }

  static T _generateOBJ<T>(json) {
    switch (T.toString()) {
      case "LoginEntity":return LoginEntity.fromJson(json) as T;
      case "NewsEntity":return NewsEntity.fromJson(json) as T;
      case "UserEntity":return UserEntity.fromJson(json) as T;
      case "homeClassEntity":return homeClassEntity.fromJson(json) as T;
      case "UploadEntity":return UploadEntity.fromJson(json) as T;
      case "studentReviewEntity":return studentReviewEntity.fromJson(json) as T;
      case "homeWorkListEntity":return homeWorkListEntity.fromJson(json) as T;
      case "attendanceRecordEntity":return attendanceRecordEntity.fromJson(json) as T;
      case "MessageEntity":return MessageEntity.fromJson(json) as T;

    }
    return null;
  }

}
